package com.leetcode.algorithm.y22.m09.w2;

import java.util.ArrayDeque;
import java.util.Deque;

/**
 * 1598. 文件夹操作日志搜集器
 * 
 * https://leetcode.cn/problems/crawler-log-folder/
 * 
 * @author jie.deng
 *
 */
class Question1598Solution01 {

	public int minOperations(String[] logs) {
		Deque<String> stack = new ArrayDeque<>();
		for (int i = 0; i < logs.length; i++) {
			String log = logs[i];
			if (log.equals("../")) {
				if (!stack.isEmpty()) {
					stack.pollLast();
				}
			} else if (!log.equals("./")) {
				stack.offerLast(log);
			}
		}

		return stack.size();
	}

}